﻿using Dapper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YinfangWeb.BLL.Model;
using YinfangWeb.Model;

namespace YinfangWeb.DAL
{
  public partial class ProductNoLibDAO
    {
        public ProductNoLib GetNo(IDbTransaction trans)
        {
            //锁表操作：保证取得唯一的编号
            var sql = "SELECT TOP 1 * FROM ProductNoLib WITH(TABLOCKX) ORDER BY NoOrder";
            using (var conn = ConnectionFactory.CreateConnection())
            {
                var model = conn.QueryFirstOrDefault<ProductNoLib>(sql,trans);
                return model;
            }
        }
    }
}
